home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / WDELCH.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  90 lines

  1. #ifndef NO_MEMORY_H
  2. #include <memory.h>
  3. #endif
  4. #define        CURSES_LIBRARY  1
  5. #include <curses.h>
  6. #undef wdelch
  7.  
  8. #ifndef        NDEBUG
  9. char *rcsid_wdelch = "$Header: c:/curses/portable/RCS/wdelch.c%v 2.0 1992/11/15 03:29:23 MH Rel $";
  10. #endif
  11.  
  12.  
  13.  
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   wdelch()     - remove character from window
  18.  
  19.   X/Open Description:
  20.        The character under the cursor in the window is deleted.  All
  21.        characters to the right on the same line are moved to the left
  22.        one position and the last character on the line is filled with
  23.        a blank.  The cursor position does not change (after moving to
  24.        y, x if coordinates are specified).
  25.  
  26.        NOTE: delch(), mvdelch(), and mvwdelch() are macros.
  27.  
  28.   PDCurses Description:
  29.        Nothing additional.
  30.  
  31.   X/Open Return Value:
  32.        The wdelch() function returns OK on success and ERR on error.
  33.  
  34.   X/Open Errors:
  35.        No errors are defined for this function.
  36.  
  37.   Portability:
  38.        PDCurses        int wdelch( WINDOW* win );
  39.        X/Open Dec '88  int wdelch( WINDOW* win );
  40.        BSD Curses      int wdelch( WINDOW* win );
  41.        SYS V Curses    int wdelch( WINDOW* win );
  42.  
  43. **man-end**********************************************************************/
  44.  
  45. int    wdelch(WINDOW *win)
  46. {
  47.        int             y;
  48.        int             x;
  49.        int             maxx;
  50.        chtype*         temp1;
  51. register chtype*       dstp;
  52. register chtype*       srcp;
  53.  
  54.        if (win == (WINDOW *)NULL)
  55.                return (ERR);
  56.  
  57.        y       = win->_cury;
  58.        x       = win->_curx;
  59.        maxx    = win->_maxx - 1;
  60.        temp1   = &win->_y[y][x];
  61.  
  62. #if    defined(DOS) || defined(OS2)
  63. #  if  SMALL || MEDIUM
  64. /*     srcp = temp1 + sizeof(chtype); */
  65.        srcp = temp1 + 1;
  66.        dstp = temp1;
  67.        movedata(FP_SEG(srcp), FP_OFF(srcp),
  68.                 FP_SEG(dstp), FP_OFF(dstp),
  69.                 (maxx - x) * sizeof(chtype));
  70. #  else
  71.        /* Changed from memcpy to memmove. Should work with
  72.         * TC and MSC.
  73.         *      -- MH   920605
  74.         */
  75. /*     memmove( temp1, temp1 + sizeof(chtype), (maxx - x) * sizeof(chtype) );*/
  76.        memmove( temp1, temp1 + 1, (maxx - x) * sizeof(chtype) );
  77. #  endif
  78. #endif
  79.  
  80.        win->_y[y][maxx] = win->_blank | win->_attrs;
  81.        win->_lastch[y] = maxx;
  82.  
  83.        if ((win->_firstch[y] == _NO_CHANGE) ||
  84.            (win->_firstch[y] > x))
  85.        {
  86.                win->_firstch[y] = x;
  87.        }
  88.        return (OK);
  89. }
  90.